package org.alps.pattern.singleton.lazy;

/**
 * @date 2021-04-30
 * @author zkw
 */
public class LazySimpleSingleton {

    private LazySimpleSingleton(){}

    private static LazySimpleSingleton lazy = null;

    /**
     * 线程安全
     * synchronized在jdk1.6之后性能优化了不少，但不可避免地还是存在一定性能问题
     * @return
     */
    public synchronized static LazySimpleSingleton getInstance() {
        if (lazy == null) {
            lazy = new LazySimpleSingleton();
        }
        return lazy;
    }
}
